<?php
$this->pageTitle = Yii::app()->name . ' - ' .
        Yii::t("UserModule.user", "Profile");

$this->breadcrumbs = array(
    Yii::t("UserModule.user", "Profile"),
);
?>
<div>
    <div style="width:50%;float:left;"><h2><?php echo Yii::t("UserModule.user", 'My profile'); ?></h2></div><div align="right" style="width:50%; float:right; font-weight:bold;"><a href="<?php echo Yii::app()->createUrl('user/profile/updateprofile'); ?>">Update Profile</a></div>
</div>
<?php if (Yii::app()->user->hasFlash('profileMessage')): ?>
    <div class="success">
        <?php echo Yii::app()->user->getFlash('profileMessage'); ?>
    </div>
<?php endif; ?>
<table class="dataGrid">
    <tr>
        <th class="label"><?php echo CHtml::encode($model->getAttributeLabel('username')); ?>
        </th>
        <td><?php echo CHtml::encode($model->username); ?>
        </td>
    </tr>
    <?php
    $profileFields = Profile::model()->findAll();

    if ($profileFields) {
        foreach ($profileFields as $field) {
            ?>
            <tr>
                <th class="label"><?php echo CHtml::encode(Yii::t("UserModule.user", $field->first_name)); ?>
                </th>
                <td><?php echo CHtml::encode($profile->getAttribute($field->first_name)); ?>
                </td>
            </tr>

            <tr>
                <th class="label"><?php echo CHtml::encode(Yii::t("UserModule.user", $field->last_name)); ?>
                </th>
                <td><?php echo CHtml::encode($profile->getAttribute($field->last_name)); ?>
                </td>
            </tr>


            <?php
        }
    }
    ?>
    <tr>
        <th class="label"><?php echo CHtml::encode($model->getAttributeLabel('password')); ?>
        </th>
        <td><?php echo CHtml::link(Yii::t("UserModule.user", "Change password"), array("changepassword")); ?>
        </td>
    </tr>
    <tr>
        <th class="label"><?php echo CHtml::encode($model->getAttributeLabel('createtime')); ?>
        </th>
        <td><?php echo date(UserModule::$dateFormat, $model->createtime); ?>
        </td>
    </tr>
    <tr>
        <th class="label"><?php echo CHtml::encode($model->getAttributeLabel('lastvisit')); ?>
        </th>
        <td><?php echo date(UserModule::$dateFormat, $model->lastvisit); ?>
        </td>
    </tr>
    <tr>
        <th class="label"><?php echo CHtml::encode($model->getAttributeLabel('status')); ?>
        </th>
        <td><?php echo CHtml::encode(User::itemAlias("UserStatus", $model->status));
    ?>
        </td>
    </tr>
</table>
